<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%> 
 
<div style="margin:20px 0;"></div>
<div class="easyui-panel" >
	<div style="padding:10px 60px 20px 60px">
    <form id="codeForm"  name="codeForm" method="post" >
    	<input type="hidden" name="code_uuid" value="${appCodeListEntity.code_uuid}"/>
    	<table cellpadding="5" style="width:100%">
    		<tr>
    			<td>参数类型:</td>
    			<td><input class="easyui-textbox" type="text" name="code_tp" data-options="required:true,validType:['checkcodetp']" value="${appCodeListEntity.code_tp }"></input></td>    	     			
    		</tr>
    		<tr>
    			<td>参数名称:</td>
    			<td><input class="easyui-textbox" type="text"  name="code_name" data-options="required:true,validType:['length[0,30]']" value="${appCodeListEntity.code_name}"></input></td>    		     			
    		</tr>
    		<tr>
    			<td>参数代码:</td>
    			<td><input class="easyui-textbox" type="text"  name="code_val" data-options="required:true,validType:['length[0,30]']" value="${appCodeListEntity.code_val}"></input></td>    		     			
    		</tr>
    		<tr>
    			<td>参数描述:</td>
    			<td><input class="easyui-textbox" name="code_desc" data-options="multiline:true,required:true,validType:['length[0,500]']" style="height:60px" value="${appCodeListEntity.code_desc }"></input></td>
    		</tr>    		 
    	</table>
    
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-save" id="saveBtn">保存</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-back" onclick="back()">返回</a>
	    </div>
    </form>
    </div>
</div>
<script>
$(document).ready(function() {
	$.extend($.fn.textbox.defaults.rules, {           
		checkcodetp: {     
            validator: function(value){               
                 var reg = new RegExp("^[a-zA-Z0-9_]{0,25}$"); 
                 return reg.test(value);  
            },     
            message: '参数类型需为0-25位数字字母或“_”'     
        }
	});
	$("#saveBtn").click(function(){	
		if($("#codeForm").form("validate")){			
			var options ={   
		            url:'<c:url value="/codelist/checkCode.do"/>',   
		            type:'post',                    
		            success:function(data){
		            	  var result=data;
						  if("success"==result){					  
							  //表单提交的方法、比如ajax提交
					    	  $("#codeForm").attr("action","../codelist/saveCode.do?");
					    	  document.getElementById("codeForm").submit();  						  
						  }else{
							  $.jpmessage.info('同一参数类型下参数代码不能重复!');
						  }
		            }   
		         };
			$("#codeForm").ajaxSubmit(options); 
		}
		
	});
	
});
 
	
</script>